home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Dots & Pixels / sources / port.cp < prev    next >
Text File  |  1995-09-29  |  2KB  |  102 lines

  1. #include <stdlib.h>
  2.  
  3. #include <Windows.h>
  4. #include <QDOffscreen.h>
  5.  
  6. #include <Fonts.h>
  7. #include <Packages.h>
  8. #include <SegLoad.h>
  9. #include <ToolUtils.h>
  10. #include <TextEdit.h>
  11.  
  12. #include "general.h"
  13. #include "port.h"
  14.  
  15. const port *port::currentport = 0;
  16.  
  17. port::~port()
  18. {
  19.     if( currentport == this)
  20.     {
  21.         //
  22.         // about to delete the current port. To be safe,
  23.         // set the current port to something else.
  24.         //
  25.         SetPort( qd.thePort);
  26.         currentport = 0;
  27.     }
  28. }
  29.  
  30. void port::use() const
  31. {
  32.     if( currentport != this)
  33.     {
  34.         currentport = this;
  35.         SetGWorld( myGWorldPtr, myGDHandle);
  36.         CheckForError( QDError(), "SetGWorld");
  37.     }
  38. }
  39.  
  40. void port::copyfrom( const port &source, const Rect &origRect,
  41.             const Rect &destRect, const short mode, const RgnHandle maskRgn) const
  42. {
  43.     use();
  44.     CopyBits( (BitMapPtr)(source.myPix), (BitMapPtr)myPix,
  45.                         &origRect, &destRect, mode, maskRgn);
  46. }
  47.  
  48. void port::copyfrom( const port &source, const Rect &origRect,
  49.                         const short mode, const RgnHandle maskRgn) const
  50. {
  51.     use();
  52.     CopyBits( (BitMapPtr)(source.myPix), (BitMapPtr)myPix,
  53.                         &origRect, &myRect, mode, maskRgn);
  54. }
  55.  
  56. void port::copyfrom( const port &source, const port &mask,
  57.                     const short mode, const RgnHandle maskRgn) const
  58. {
  59.     use();
  60.     CopyDeepMask( (BitMapPtr)(source.myPix), (BitMapPtr)(mask.myPix), (BitMapPtr)myPix,
  61.                     &source.myRect, &mask.myRect, &myRect, mode, maskRgn);
  62. }
  63.  
  64. void port::copyfrom( const port &source, const port &mask, const Rect &origRect,
  65.                     const Rect &maskRect, const Rect &destRect,
  66.                     const short mode, const RgnHandle maskRgn) const
  67. {
  68.     use();
  69.     CopyDeepMask( (BitMapPtr)(source.myPix), (BitMapPtr)(mask.myPix), (BitMapPtr)myPix,
  70.                         &origRect, &maskRect, &destRect, mode, maskRgn);
  71. }
  72.  
  73. void port::scroll( short dh, short dv) const
  74. {
  75.     use();
  76.     RgnHandle updateRgn = NewRgn();
  77.     ScrollRect( &myGWorldPtr->portRect, dh, dv, updateRgn);
  78.     DisposeRgn( updateRgn);
  79. }
  80.  
  81. PicHandle port::getPICT() const
  82. {
  83.     use();
  84.     PicHandle thePICT = OpenPicture( &myGWorldPtr->portRect);
  85.     CopyBits( (BitMapPtr)myPix, (BitMapPtr)myPix, &myRect, &myRect, srcCopy + ditherCopy, 0L);
  86.     ClosePicture();
  87.     return thePICT;
  88. }
  89.  
  90. void port::SetColorTable( short resID) const
  91. {
  92.     CTabHandle theColorTable = GetCTable( resID);
  93.     SetColorTable( theColorTable);
  94. }
  95.  
  96. void port::SetColorTable( CTabHandle theColorTable) const
  97. {
  98.     DisposeCTable( myPix->pmTable);
  99.     myPix->pmTable = theColorTable;
  100.     GDeviceChanged( myGDHandle);
  101. }
  102.